package com.ttn.connection.bus;

import java.util.Date;

import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
import org.springframework.stereotype.Service;

import com.ttn.entities.Connection;
import com.ttn.entities.User;

@Service
public class ConnectionService extends HibernateDaoSupport {
	
	
	
	public void saveConnection(Connection connection) throws Exception{
		this.getHibernateTemplate().save(connection)	;
	}
	
	
	@Autowired
	public void init(SessionFactory factory) {
	    setSessionFactory(factory);
	}
	
	
	public Connection createEmptyConnection(User user)  {
		Connection connection =  new Connection();
		connection.setTripDate(new Date());		
		connection.setUser(user);
		return connection;
	}
	
	
	
}
